﻿using System;
using System.Web;

/// <summary>
/// 对象缓存池
/// </summary>
public static class CacheMan
{
	//返回系统配置对象，若尚未缓存则从数据库中读取，返回时顺带缓存该对象
	public static SystemConfigure GetSystemConfigure()
	{
		SystemConfigure cfg = Get<SystemConfigure>(SYSTEM_CONFIGURE);
		if (cfg==null)
		{
			cfg = DAMS.DataAccess.GetSystemConfigure();
			Put(SYSTEM_CONFIGURE, cfg);
		}
		return cfg;
	}
	private const String SYSTEM_CONFIGURE = "SystemConfigure";
	private static void Put(String keyword,Object obj)
	{
		HttpContext.Current.Cache.Insert(keyword,obj);
	}
	private static T Get<T>(String keyword)
	{
		return (T)HttpContext.Current.Cache.Get(keyword);
	}
}
